-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exam mode
: Add exam rescheduled event
#10026
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces a new feature for handling exam rescheduling events within the Artemis platform. It includes the creation of a new Changes
Suggested Labels
Suggested Reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🔭 Outside diff range comments (1)
src/main/webapp/app/exam/participate/exam-start-information/exam-start-information.component.ts (1)
Line range hint
51-62
: Add null checks for optional propertiesThe updateInformationBoxes method should include null checks for optional properties to prevent potential runtime errors.
private updateInformationBoxes(): void { + if (!this.exam || !this.studentExam) { + return; + } this.totalPoints = this.exam.examMaxPoints; this.totalWorkingTimeInMinutes = Math.floor(this.exam.workingTime! / 60); this.moduleNumber = this.exam.moduleNumber; this.courseName = this.exam.courseName; this.examiner = this.exam.examiner; this.numberOfExercisesInExam = this.exam.numberOfExercisesInExam; this.examinedStudent = this.studentExam.user?.name; this.startDate = this.exam.startDate; - this.gracePeriodInMinutes = Math.floor(this.exam.gracePeriod! / 60); + this.gracePeriodInMinutes = this.exam.gracePeriod ? Math.floor(this.exam.gracePeriod / 60) : undefined;
🧹 Nitpick comments (10)
src/main/webapp/app/exam/participate/exam-participation.component.ts (1)
674-674
: Simplify object property assignment using ES6 shorthandYou can use ES6 property shorthand to make the code more concise.
Apply this diff to simplify the object assignment:
- this.exam = { ...this.exam, startDate: startDate, endDate: endDate }; + this.exam = { ...this.exam, startDate, endDate };src/test/javascript/spec/component/exam/participate/exam-participation.component.spec.ts (1)
155-158
: Ensure consistent use of date handling in testsThe use of
dayjs()
is appropriate for mocking dates. However, ensure that all test cases consistently use the mocked server date to prevent flakiness.No action needed if consistency is already maintained across tests.
src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamRescheduledEventDTO.java (1)
14-14
: Consider usingInstant
for date fields for consistencyTo maintain consistency with other DTOs and avoid potential serialization issues, consider using
Instant
instead ofZonedDateTime
fornewStartDate
andnewEndDate
.Apply this diff to replace
ZonedDateTime
withInstant
:- public record ExamRescheduledEventDTO(Long id, String createdBy, Instant createdDate, ZonedDateTime newStartDate, ZonedDateTime newEndDate) implements ExamLiveEventBaseDTO { + public record ExamRescheduledEventDTO(Long id, String createdBy, Instant createdDate, Instant newStartDate, Instant newEndDate) implements ExamLiveEventBaseDTO {src/main/webapp/app/exam/shared/events/exam-live-event.component.scss (1)
47-57
: Reduce style duplication using a shared classThe
.wt-title
styles are duplicated between.workingTimeUpdate
and.examRescheduled
classes.Extract common styles:
+ %event-title { + font-weight: bold; + font-size: 1.5em; + text-align: center; + margin-bottom: 15px; + } &.workingTimeUpdate { background-color: var(--artemis-alert-warning-background); border-color: var(--artemis-alert-warning-border); .wt-title { - font-weight: bold; - font-size: 1.5em; - text-align: center; - margin-bottom: 15px; + @extend %event-title; } } &.examRescheduled { background-color: var(--artemis-alert-warning-background); border-color: var(--artemis-alert-warning-border); .wt-title { - font-weight: bold; - font-size: 1.5em; - text-align: center; - margin-bottom: 15px; + @extend %event-title; } }src/main/webapp/app/exam/participate/events/exam-live-events-button.component.ts (1)
17-21
: Consider improving constant name and adding documentationWhile the separation of events is logical, the purpose of
USER_DISPLAY_RELEVANT_EVENTS_REOPEN
is not immediately clear. Consider:
- Renaming to something more descriptive like
EXAM_PRE_START_RELEVANT_EVENTS
- Adding JSDoc comments explaining when each constant should be used
-export const USER_DISPLAY_RELEVANT_EVENTS_REOPEN = [ +/** Events that are relevant before the exam starts and can trigger reopening of the event dialog */ +export const EXAM_PRE_START_RELEVANT_EVENTS = [src/main/webapp/app/exam/shared/events/exam-live-event.component.html (1)
74-82
: LGTM with a minor accessibility enhancement suggestionThe implementation of the exam rescheduled event case is correct and follows Angular best practices. Consider adding an ARIA label for better screen reader support.
@case (ExamLiveEventType.EXAM_RESCHEDULED) { <div> <div [jhiTranslate]="'artemisApp.exam.events.messages.examRescheduled.description'" [translateValues]="{ startDate: examRescheduledEvent.newStartDate | artemisDate, endDate: examRescheduledEvent.newEndDate | artemisDate }" class="wt-title" + role="alert" + aria-live="polite" ></div> </div> }src/main/webapp/app/exam/participate/exam-start-information/exam-start-information.component.ts (1)
35-40
: Consider optimizing change detectionWhile the implementation is correct, consider adding change detection optimization to prevent unnecessary updates:
- ngOnChanges(): void { + ngOnChanges(changes: SimpleChanges): void { + // Only update if exam or studentExam inputs have changed + if (changes['exam'] || changes['studentExam']) { this.updateInformationBoxes(); + } }src/main/webapp/app/exam/participate/exam-participation-live-events.service.ts (1)
56-59
: Consider timezone handling for datesThe date fields should explicitly handle timezone conversions to prevent any potential timezone-related issues.
Consider using a utility function:
export type ExamRescheduledEvent = ExamLiveEvent & { - newStartDate: dayjs.Dayjs; - newEndDate: dayjs.Dayjs; + newStartDate: dayjs.Dayjs & { utc: true }; + newEndDate: dayjs.Dayjs & { utc: true }; };src/main/webapp/i18n/en/exam.json (1)
190-191
: Enhance message clarityThe current message could be more informative about the implications of the rescheduling.
Consider this improved message:
- "examRescheduled": "Exam rescheduled" + "examRescheduled": "Exam schedule changed" "description": "The exam has been rescheduled.<br />The exam will take place from {{ startDate }} to {{ endDate }}.<br />The working time has not been affected." + "description": "Important: The exam schedule has been updated.<br />New exam time: {{ startDate }} to {{ endDate }}.<br />Note: Your allocated working time remains unchanged. Please adjust your schedule accordingly."Also applies to: 211-212
src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java (1)
1450-1451
: Improve clarity of comments and conditions.The current comment and condition could be more explicit about the logic:
-// If the old working time equals the new working time, the exam has been rescheduled -if (studentExam.getWorkingTime().equals(originalStudentWorkingTime)) { +// If the working time hasn't changed, this update is for rescheduling the exam dates +if (Objects.equals(studentExam.getWorkingTime(), originalStudentWorkingTime)) {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
src/main/resources/config/liquibase/changelog/20241211131711_changelog.xml
is excluded by!**/*.xml
src/main/resources/config/liquibase/master.xml
is excluded by!**/*.xml
📒 Files selected for processing (15)
src/main/java/de/tum/cit/aet/artemis/exam/domain/event/ExamRescheduledEvent.java
(1 hunks)src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamLiveEventBaseDTO.java
(1 hunks)src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamRescheduledEventDTO.java
(1 hunks)src/main/java/de/tum/cit/aet/artemis/exam/service/ExamLiveEventsService.java
(2 hunks)src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java
(1 hunks)src/main/webapp/app/exam/participate/events/exam-live-events-button.component.ts
(1 hunks)src/main/webapp/app/exam/participate/exam-participation-live-events.service.ts
(3 hunks)src/main/webapp/app/exam/participate/exam-participation.component.ts
(6 hunks)src/main/webapp/app/exam/participate/exam-start-information/exam-start-information.component.ts
(4 hunks)src/main/webapp/app/exam/shared/events/exam-live-event.component.html
(1 hunks)src/main/webapp/app/exam/shared/events/exam-live-event.component.scss
(1 hunks)src/main/webapp/app/exam/shared/events/exam-live-event.component.ts
(2 hunks)src/main/webapp/i18n/de/exam.json
(2 hunks)src/main/webapp/i18n/en/exam.json
(2 hunks)src/test/javascript/spec/component/exam/participate/exam-participation.component.spec.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamLiveEventBaseDTO.java (1)
Pattern src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports
src/main/webapp/app/exam/shared/events/exam-live-event.component.html (1)
Pattern src/main/webapp/**/*.html
: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.
src/main/webapp/app/exam/shared/events/exam-live-event.component.ts (1)
src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamRescheduledEventDTO.java (1)
Pattern src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports
src/main/java/de/tum/cit/aet/artemis/exam/service/ExamLiveEventsService.java (1)
Pattern src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports
src/main/webapp/app/exam/participate/events/exam-live-events-button.component.ts (1)
src/main/webapp/app/exam/participate/exam-start-information/exam-start-information.component.ts (1)
src/main/webapp/i18n/de/exam.json (1)
Pattern src/main/webapp/i18n/de/**/*.json
: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".
src/main/webapp/app/exam/participate/exam-participation-live-events.service.ts (1)
src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java (1)
Pattern src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports
src/test/javascript/spec/component/exam/participate/exam-participation.component.spec.ts (1)
Pattern src/test/javascript/spec/**/*.ts
: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}
src/main/webapp/app/exam/participate/exam-participation.component.ts (1)
src/main/java/de/tum/cit/aet/artemis/exam/domain/event/ExamRescheduledEvent.java (1)
Pattern src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports
📓 Learnings (1)
src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java (1)
Learnt from: SamuelRoettgermann
PR: ls1intum/Artemis#9303
File: src/main/java/de/tum/in/www1/artemis/service/exam/StudentExamService.java:266-267
Timestamp: 2024-11-12T12:51:58.050Z
Learning: When reviewing code in this project, avoid suggesting code changes that are outside the scope of the PR.
🔇 Additional comments (8)
src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamLiveEventBaseDTO.java (1)
20-20
: Addition of ExamRescheduledEventDTO
is correctly implemented
The new subtype ExamRescheduledEventDTO
has been appropriately added to the @JsonSubTypes
annotation.
src/main/webapp/app/exam/participate/events/exam-live-events-button.component.ts (1)
15-16
: LGTM: Event type addition is correct
The addition of ExamLiveEventType.EXAM_RESCHEDULED
to the relevant events array is appropriate and aligns with the PR objectives.
src/main/webapp/app/exam/participate/exam-start-information/exam-start-information.component.ts (1)
1-1
: LGTM: Proper implementation of OnChanges
The addition of the OnChanges interface is appropriate for handling reactive updates to exam information.
Also applies to: 17-17
src/main/webapp/app/exam/participate/exam-participation-live-events.service.ts (2)
23-23
: LGTM: Event type addition
The new event type follows the established naming convention.
195-198
: Review auto-acknowledgment behavior
While auto-acknowledging rescheduled events prevents notification spam, it might hide important information from users who navigate to the exam page after the event was sent.
Let's verify the impact:
Consider adding a visual indicator in the UI that shows the exam was rescheduled, even if the event is auto-acknowledged.
src/main/webapp/i18n/de/exam.json (2)
190-191
: LGTM! Translation for exam rescheduled event type.
The German translation "Prüfung verschoben" is appropriate and follows the informal style (dutzen) guideline.
211-213
: LGTM! Translation for exam rescheduled event message.
The German message is well-structured with:
- Clear communication of the schedule change
- Proper placeholders for dates
- Important note about unchanged working time
- Consistent formatting with other messages
src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java (1)
1448-1458
: Verify the impact of exam rescheduling.
The rescheduling logic assumes that equal working times indicate a reschedule. Please verify:
- That this assumption holds true for all cases
- That there are no edge cases where working time equality could lead to incorrect event type selection
✅ Verification successful
Based on the search results, I can now generate a final response as we have sufficient evidence from the codebase:
The exam rescheduling logic is correctly implemented and documented
The assumption about equal working times indicating a reschedule is valid because:
- The
ExamRescheduledEvent
class explicitly documents: "An event indicating that the exam's start and end dates have been rescheduled. The working time remains unchanged in such cases." - The implementation correctly separates working time changes from rescheduling events:
- Working time changes trigger
WorkingTimeUpdateEvent
- Date changes (with unchanged working time) trigger
ExamRescheduledEvent
- Working time changes trigger
The logic is consistent across the codebase and there are no edge cases where working time equality could lead to incorrect event selection, as the system:
- Handles working time changes during conduction separately via dedicated message topics
- Has distinct handling paths for rescheduling vs working time updates
- Maintains clear separation between date changes and duration changes in the event system
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other places where exam rescheduling is handled to verify consistency
rg -A 5 "exam.*reschedul"
# Search for test cases to verify the rescheduling logic
ast-grep --pattern 'test.*reschedul.*exam'
Length of output: 9430
src/main/java/de/tum/cit/aet/artemis/exam/domain/event/ExamRescheduledEvent.java
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/exam/domain/event/ExamRescheduledEvent.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/exam/domain/event/ExamRescheduledEvent.java
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/exam/service/ExamLiveEventsService.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notifications should appear in the list when you click the button in the top-right corner (as shown in your picture). However, the modal should not open automatically if you navigate to the exam page after the exam has been rescheduled. The pop-up should only appear automatically if the reschedule event occurs while you are already on the exam page. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS1, everything works as intended
Checklist
General
Server
(https://docs.artemis.cit.tum.de/dev/guidelines/server/#rest-endpoint-best-practices-for-authorization) and checked the course groups for all new REST Calls (security).
Client
Motivation and Context
When the exam start and end dates are adjusted while the exam is already visible, but the duration remains unchanged (e.g., postponing the exam by 10 minutes), this currently triggers a working time update event in the client, which can be confusing since the working time is not affected. This pull request introduces a new live exam event type called
ExamRescheduled
to handle such cases more clearly.Description
A new event called ExamRescheduled has been implemented on the server side. This event is triggered only when the exam is visible and before its start date, as postponing an exam that has already started would be irrelevant. The client side has also been updated to handle this new event type appropriately. The notification is shown only if the user is currently viewing the exam start page. If the user navigates to the exam page after the event has been sent, it is automatically acknowledged, as the exam page already reflects the updated exam information.
Steps for Testing
Prerequisites:
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Performance Review
Code Review
Manual Tests
Coverage
Client
Client
Server
Screenshots
Light mode
Dark mode
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests